package com.cfh.springcloudserver.web.mvc;

import com.cfh.springcloudserver.controller.ServerController;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.IOException;
import java.io.Writer;
import java.util.concurrent.TimeoutException;

@RestControllerAdvice(assignableTypes = ServerController.class)
public class CircuitBreakerRestControllerAdvice {

    @ExceptionHandler
    public void onTimeoutException(TimeoutException timeoutExcepton, Writer writer) {
        try {
            writer.write("Default");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
